<?php
$con = mysql_connect("localhost","cubeMass_f","cubeSelectNow");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// Create table in my_db database
mysql_select_db("cubeMass", $con);
/*
//create user-----------------------------------------------------------------------
$sql = "CREATE TABLE user"
."("
."ID 			INT 			UNSIGNED NOT NULL AUTO_INCREMENT,"
."name			VARCHAR(255) 	CHARACTER SET ASCII NOT NULL,"
."nickName		VARCHAR(255) 	CHARACTER SET UTF8 NOT NULL,"
."password		VARCHAR(255)	CHARACTER SET ASCII NOT NULL,"
."createTime 	DATETIME		DEFAULT '0000-00-00 00:00:00',"
."lastLoginTime DATETIME		DEFAULT '0000-00-00 00:00:00',"
."passwordQ 	TINYTEXT 		CHARACTER SET UTF8,"
."passwordA 	TINYTEXT 		CHARACTER SET UTF8,"
."loginIp 		TINYTEXT		CHARACTER SET ASCII,"
."lastLoginIp 	TINYTEXT		CHARACTER SET ASCII,"
."email			TINYTEXT		CHARACTER SET ASCII NOT NULL,"
."loginTimes 	MEDIUMINT		UNSIGNED DEFAULT '0',"
."rank 			TINYINT			DEFAULT '0',"
."gold 			MEDIUMINT		DEFAULT '0',"
."PRIMARY KEY (ID),"
."CONSTRAINT userName UNIQUE (name)"
.")"
."TYPE = INNODB CHARACTER SET = ASCII COMMENT = 'User\'s infomation'";
mysql_query($sql,$con);

$sql = "ALTER TABLE user AUTO_INCREMENT = 10000";
mysql_query($sql,$con);

//create user bose
$sql = "INSERT INTO user"
."(name,password)"
."VALUES('boss','54d8aef41959740d80d066f49f752614')";
mysql_query($sql,$con);

//create model ----------------------------------------------------------------------
$sql = "CREATE TABLE model"
."("
."ID 			BIGINT 			UNSIGNED NOT NULL AUTO_INCREMENT,"
."AUTHOR_ID 	INT				UNSIGNED DEFAULT '10000' NOT NULL,"
."USER_ID 		INT 			UNSIGNED DEFAULT '10000' NOT NULL,"
."name 			VARCHAR(255) 	CHARACTER SET UTF8 NOT NULL,"
."description 	VARCHAR(255) 	CHARACTER SET UTF8 NOT NULL,"
."stringData 	MEDIUMTEXT 		CHARACTER SET ASCII NOT NULL,"
."visitedTimes 	MEDIUMINT 		UNSIGNED DEFAULT '0',"
."editTimes 	MEDIUMINT 		UNSIGNED DEFAULT '0',"
."dealTimes 	MEDIUMINT 		UNSIGNED DEFAULT '0',"
."discussTimes	MEDIUMINT		UNSIGNED DEFAULT '0',"
."picSrc 		TINYTEXT 		CHARACTER SET ASCII,"
."createTime 	DATETIME 		DEFAULT '0000-00-00 00:00:00',"
."lastEditTime 	DATETIME 		DEFAULT '0000-00-00 00:00:00',"
."rank 			FLOAT(7)		DEFAULT '0',"
."rankTimes 	MEDIUMINT		DEFAULT '0',"
."state 		TINYINT			DEFAULT '0',"
."PRIMARY KEY (ID),"
."CONSTRAINT modelPerUser FOREIGN KEY (USER_ID) REFERENCES user(ID),"
."CONSTRAINT modelCreater FOREIGN KEY (AUTHOR_ID) REFERENCES user(ID)"
.")"
."TYPE = INNODB CHARACTER SET = ASCII COMMENT = 'Model\'s Data'";
mysql_query($sql,$con);

$sql = "ALTER TABLE model AUTO_INCREMENT = 10000";
mysql_query($sql,$con);

//create model bose
$sql = "INSERT INTO model"
."(name,stringData)"
."VALUES('boss','[i0i0i0-affffffi0i0i0]')";
mysql_query($sql,$con);
*///create discuss--------------------------------------------------------------------------------
$sql = "CREATE TABLE discuss"
."("
."ID 			BIGINT 			UNSIGNED NOT NULL AUTO_INCREMENT,"
."MODEL_ID 		BIGINT			UNSIGNED DEFAULT '10000' NOT NULL,"
."USER_ID 		INT 			UNSIGNED DEFAULT '10000' NOT NULL,"
."content 		TEXT		 	CHARACTER SET UTF8 NOT NULL,"
."supportTimes 	MEDIUMINT 		UNSIGNED DEFAULT '0',"
."opposeTimes 	MEDIUMINT 		UNSIGNED DEFAULT '0',"
."createTime 	DATETIME 		DEFAULT '0000-00-00 00:00:00',"
."PRIMARY KEY (ID),"
."CONSTRAINT discussByUser FOREIGN KEY (USER_ID) REFERENCES user(ID),"
."CONSTRAINT discussForModel FOREIGN KEY (MODEL_ID) REFERENCES model(ID)"
.")"
."TYPE = INNODB CHARACTER SET = ASCII COMMENT = 'Model\'s discuss'";
mysql_query($sql,$con);

mysql_close($con);
?>